package com.hmkj.core.api.umf.domain;

import java.util.Objects;

/**
 *
 * @author 陌上人
 * @date 2077/7/7 15:05
 */
public class ResultCode {

    /**
     * 返回码说明 处理成功
     */
    public static String RESULT_CODE_OK = "0000";

    /**
     * 返回码说明 系统错误
     */
    public static String RESULT_CODE_EROOR = "00060999";

    public static String RESULT_MSG_CASHING = "提现待处理中";


    public enum ErrorCodeEnum {

        /**
         * 错误代码枚举类
         */
        SIGN_FAILED("00060710","签名验签失败"),
        PAYING("00060761","订单支付中"),
        NO_OPENED("00200013","商户未开通该银行"),
        ORDER_CREATE_FAILED("00200077","生成支付订单失败"),
        ORDER_NOT_EXISTS("00200078","支付订单不存在"),
        ORDER_CLOSED("00200080","订单已关闭"),
        NO_REPEAT_PAY("00060780","订单已支付成功,无须再次支付"),
        YZM_INCORRECT("00200083","验证码输入不正确"),
        YZM_INVALID("00200090","验证码已失效");

        private String code;
        private String msg;

        ErrorCodeEnum(String code, String msg){
            this.code = code;
            this.msg = msg;
        }

        public String getCode(){
            return code;
        }

        public String getMsg(){
            return msg;
        }

        public static ErrorCodeEnum msgOf(String index){
            for (ErrorCodeEnum code : values()) {
                if(Objects.equals(code.getCode(), index)){
                    return code;
                }
            }
            return null;
        }
    }

    public enum TradeStateEnum {

        /**
         * 错误代码枚举类
         */
        WAIT_BUYER_PAY("WAIT_BUYER_PAY","等待支付"),
        TRADE_SUCCESS("TRADE_SUCCESS","支付成功"),
        TRADE_FAIL("TRADE_FAIL","支付失败"),
        TRADE_CANCEL("TRADE_CANCEL","订单已撤销"),
        TRADE_CLOSED("TRADE_CLOSED","订单过期关闭");

        private String code;
        private String msg;

        TradeStateEnum(String code, String msg){
            this.code = code;
            this.msg = msg;
        }

        public String getCode(){
            return code;
        }

        public String getMsg(){
            return msg;
        }

        public static TradeStateEnum msgOf(String index){
            for (TradeStateEnum code : values()) {
                if(Objects.equals(code.getCode(), index)){
                    return code;
                }
            }
            return null;
        }
    }

}
